<html>
<head><meta charset="utf-8"><title>multi-crate example from blog · t-compiler/wg-self-profile · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/index.html">t-compiler/wg-self-profile</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html">multi-crate example from blog</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189393844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189393844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189393844">(Feb 29 2020 at 15:18)</a>:</h4>
<p>Hi self-profile team!</p>
<p>I just tried the multi-crate example from your recent blog post <a href="https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html" target="_blank" title="https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html">https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html</a> on my project <a href="https://github.com/HadrienG2/3photons-rust" target="_blank" title="https://github.com/HadrienG2/3photons-rust">https://github.com/HadrienG2/3photons-rust</a> , but it doesn't seem to work. In the "profiles" directory, there is just one other profile behind the one from my crate, with the weird underscore-ey name, <code>___-17023.*</code>, and it's mostly empty (all files are &lt;1kB, nothing is displayed in <code>chrome://tracing</code>).</p>
<p>The command I use to flush old data and run a profile is <code>rm profiles/* &amp;&amp; cargo clean &amp;&amp; RUSTFLAGS="-Zself-profile=./profiles -Zself-profile-events=default,args" cargo +nightly build --release &amp;&amp; crox --dir profiles/</code>.</p>
<p>Any idea what could be going wrong, and how to debug or report this?</p>



<a name="189394022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394022">(Feb 29 2020 at 15:24)</a>:</h4>
<p>I tried it on the regex repo, and the result is the same: one profile for regex-syntax, one for regex, but nothing for the dependencies (just weird almost-empty underscore-prefixed profiles).</p>
<p>This is on rustc 1.43.0-nightly (0eb878d2a 2020-02-28).</p>



<a name="189394144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394144">(Feb 29 2020 at 15:28)</a>:</h4>
<p>...and using the measureme master, as suggested by the blog post.</p>



<a name="189394154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394154">(Feb 29 2020 at 15:29)</a>:</h4>
<p>Every time cargo attempt to build something, it runs <code>rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg</code> to find the extensions for various crate types, the active <code>#[cfg]</code>, and so on. This will cause measureme profiles like <code>___-17023.*</code>.</p>



<a name="189394157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394157">(Feb 29 2020 at 15:29)</a>:</h4>
<p>(but that shouldn't matter because AFAIK the generation of those profile files is carried out by rustc iself)</p>



<a name="189394207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394207">(Feb 29 2020 at 15:30)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> I see... is that a recent change? I'm curious about how you got the profile from the blog post with all the deps.</p>



<a name="189394222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394222">(Feb 29 2020 at 15:30)</a>:</h4>
<p>And also, why do I get one empty underscore-prefixed file, rather than one per dependency with some data inside?</p>



<a name="189394278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394278">(Feb 29 2020 at 15:32)</a>:</h4>
<div class="codehilite"><pre><span></span>hadrien@spartan-graloufotron:~/Bureau/regex&gt; ll profiles/
total 38156
-rw-r--r-- 1 hadrien users       32 29 févr. 16:20 ___-18568.events
-rw-r--r-- 1 hadrien users      487 29 févr. 16:20 ___-18568.string_data
-rw-r--r-- 1 hadrien users       16 29 févr. 16:20 ___-18568.string_index
-rw-r--r-- 1 hadrien users  5478416 29 févr. 16:21 regex-18706.events
-rw-r--r-- 1 hadrien users 12077624 29 févr. 16:21 regex-18706.string_data
-rw-r--r-- 1 hadrien users  1361816 29 févr. 16:21 regex-18706.string_index
-rw-r--r-- 1 hadrien users  5583512 29 févr. 16:21 regex_syntax-18579.events
-rw-r--r-- 1 hadrien users 12946787 29 févr. 16:21 regex_syntax-18579.string_data
-rw-r--r-- 1 hadrien users  1528192 29 févr. 16:21 regex_syntax-18579.string_index
</pre></div>



<a name="189394297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394297">(Feb 29 2020 at 15:33)</a>:</h4>
<p>This is not a recent change. You get one per <code>cargo build</code>, as cargo only performs the aforementioned once per <code>cargo build</code>. The blog post uses <code>cargo rustc -- -Zself-profile</code> instead of setting <code>RUSTFLAGS</code>, which means that <code>-Zself-profile</code> is only passed when the target crate is build, instead of being passed for every rustc invocation.</p>



<a name="189394344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394344">(Feb 29 2020 at 15:34)</a>:</h4>
<p>That's the beginning of the blog post indeed. But at the end, there's a multi-crate example using rustflags.</p>



<a name="189394346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394346">(Feb 29 2020 at 15:34)</a>:</h4>
<p>Which is what I was trying to replicate here.</p>



<a name="189394349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394349">(Feb 29 2020 at 15:35)</a>:</h4>
<p><a href="https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html#profiling-an-entire-crate-graph" target="_blank" title="https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html#profiling-an-entire-crate-graph">https://blog.rust-lang.org/inside-rust/2020/02/25/intro-rustc-self-profile.html#profiling-an-entire-crate-graph</a></p>



<a name="189394360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394360">(Feb 29 2020 at 15:35)</a>:</h4>
<p>The <code>___-*.*</code> files are empty, because the rustc doesn't perform any actual compilation work for it, so there is nothing to record.</p>



<a name="189394419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394419">(Feb 29 2020 at 15:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211871">Hadrien Grasland</span> <a href="#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/multi-crate.20example.20from.20blog/near/189394344" title="#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/multi-crate.20example.20from.20blog/near/189394344">said</a>:</p>
<blockquote>
<p>That's the beginning of the blog post indeed. But at the end, there's a multi-crate example using rustflags.</p>
</blockquote>
<p>I see it now. The <code>___-*.*</code> shouldn't give any problems. Just run <code>crox --dir profiles</code>.</p>



<a name="189394484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394484">(Feb 29 2020 at 15:38)</a>:</h4>
<p>This works, but it will only feature the regex and regex-syntax profiles, not those of the dependencies as seen on <a href="https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png" target="_blank" title="https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png">https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png</a></p>
<div class="message_inline_image"><a href="https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png" target="_blank" title="https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png"><img src="https://blog.rust-lang.org/images/inside-rust/2020-02-25-intro-rustc-self-profile/chrome_profiler3.png"></a></div>



<a name="189394511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394511">(Feb 29 2020 at 15:39)</a>:</h4>
<p>Can you post a screenshot?</p>



<a name="189394566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394566">(Feb 29 2020 at 15:40)</a>:</h4>
<p><a href="/user_uploads/4715/dlX4eJHkqy5n51fWo3_z5mMt/Capture-décran-du-2020-02-29-16-40-25.png" target="_blank" title="Capture-décran-du-2020-02-29-16-40-25.png">Capture-décran-du-2020-02-29-16-40-25.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/dlX4eJHkqy5n51fWo3_z5mMt/Capture-décran-du-2020-02-29-16-40-25.png" target="_blank" title="Capture-décran-du-2020-02-29-16-40-25.png"><img src="/user_uploads/4715/dlX4eJHkqy5n51fWo3_z5mMt/Capture-décran-du-2020-02-29-16-40-25.png"></a></div>



<a name="189394769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394769">(Feb 29 2020 at 15:46)</a>:</h4>
<p>Found the problem: dependencies outside of the current workspace will have the current working dir of the rustc instance switched to their source directory. Because you specified the profile dir as a relative path, that means that the profiles will end up in a different directory for those dependencies. Replacing <code>-Zself-profile=./profiles</code> with <code>-Zself-profile=$(pwd)/profiles</code> should fix this.</p>



<a name="189394774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394774">(Feb 29 2020 at 15:47)</a>:</h4>
<p>Oh, I see!</p>



<a name="189394781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394781">(Feb 29 2020 at 15:47)</a>:</h4>
<p>Well, let me send you a blog post PR then ;)</p>



<a name="189394828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394828">(Feb 29 2020 at 15:48)</a>:</h4>
<p>Not me, I am not part of wg-self-profile :)</p>
<p>Anyway the source is at <a href="https://github.com/rust-lang/blog.rust-lang.org/blob/master/posts/inside-rust/2020-02-25-intro-rustc-self-profile.md" target="_blank" title="https://github.com/rust-lang/blog.rust-lang.org/blob/master/posts/inside-rust/2020-02-25-intro-rustc-self-profile.md">https://github.com/rust-lang/blog.rust-lang.org/blob/master/posts/inside-rust/2020-02-25-intro-rustc-self-profile.md</a></p>



<a name="189394845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hadrien Grasland <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394845">(Feb 29 2020 at 15:50)</a>:</h4>
<p>Thanks!</p>



<a name="189394896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189394896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189394896">(Feb 29 2020 at 15:50)</a>:</h4>
<p>No problem!</p>



<a name="189444574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/multi-crate%20example%20from%20blog/near/189444574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/multi-crate.20example.20from.20blog.html#189444574">(Mar 01 2020 at 19:28)</a>:</h4>
<p>Nice debugging! Yeah, you're totally correct that path should be absolute not relative to avoid this issue. I'll think about where we can document that better.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>